home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Scripts / Director.vu < prev    next >
Encoding:
Text File  |  1993-12-17  |  15.6 KB  |  431 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Director.vu
  5. #
  6. #    Contains:    Quick look test script for Director version 3.1
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #     <1.0.6>     9/28/93    KTA        Added returnVal for ModifyDocument hook.
  19. #     <1.0.3>     7/22/93    KTA        Updated references to GetGestaltMachineType() which name has
  20. #                                    been changed to GestaltMachineType().
  21. #     <1.0.2>     6/16/93    NAGA        Renaming InitGlobals(ScriptLevel)to InitGlobals(ScriptLevel)
  22. #        <1+>     5/25/93    NAGA        Adding header and porting old files to follow new standards
  23. #
  24. # ****************************************************************************
  25. #
  26.  
  27.  
  28.  
  29. ########################################################################
  30. #                            External libraries 
  31. #=======================================================================
  32. Libraries "Output.Lib", "DoTasks.Lib","Draw.Lib","Gestalt.Lib", "UserInterface.Lib","Da.Lib", "Font.Lib", "Globals.Lib", "LaunchQuit.Lib", "TCS.Lib";
  33.  
  34.  
  35. #########################################################################
  36. ########               Application Specific Tasks
  37. #########################################################################
  38.  
  39. #########################################################################
  40. #                        InitAppGlobals()
  41. #========================================================================
  42. # Author:        ML
  43. # Description:    Sets up tools and fonts for Director.  This task
  44. #                must be called first.
  45. # Parameters:    None
  46. # Returns:        Nothing
  47. # Examples:        InitAppGlobals()
  48. #========================================================================
  49. # History:
  50. #
  51. ########################################################################
  52. task InitAppGlobals()
  53. begin
  54.     
  55.     logstr("setting up {global gApptitle}'s globals");            
  56.     global kClick, kDrag, kDragClick, kMultiDrag, kMultiClickDrag, kMultiClick;
  57.     global kPalDocWind, kPalWind, kPullOffPal, kPopUpPal, kScrollPal, gTextStr ;
  58.  
  59.     global kToolPaletteNum         := 1; 
  60.     global kColorPaletteNum     := 2;
  61.     global kPatternPaletteNum     := 3;
  62.     #global kLinePaletteNum        := 4;
  63.     #global kGradientPaletteNum    := 5;
  64.     
  65.     global gPaletteList := {
  66.                             {     
  67.                             { 1,58, 51,223,1},            #Main Tool Matrix (Pallete #1)
  68.                             kPalDocWind,
  69.                             {2,8},                        #tool matrix
  70.                             {26,20}                        #tool offset
  71.                              },
  72.  
  73.                             {     
  74.                             { 18,270, 53,256,1 },        #Color Matrix (Pallete #2)
  75.                             kPopUpPal,
  76.                             {16,16},                    #tool matrix
  77.                             {8,8}                        #tool offset
  78.                             },
  79.  
  80.                             {     
  81.                             { 25,302, 54,295, 1},        #Pattern Matrix (Pallete #3)
  82.                             kPopUpPal,
  83.                             {8,8},                        #tool matrix
  84.                             {20,20}                        #tool offset
  85.                             },
  86.                             
  87.                             {                                 
  88.                             { 17,308, 42,308 },            #Line Weight Matrix (Pallete #4)
  89.                             kPalDocWind,
  90.                             {1,5},                        #tool matrix
  91.                             {0,5}                        #tool offset
  92.                             }
  93.                         };
  94.  
  95.     ### Palette Elements:=        Tool#, Pal#,     ToolName,         ToolType,    DblClktoEnd        SetAttributes
  96.     global FreeSelectTool     :=     { 1,  1,        "FreeSelect",    kMultiDrag, 0,                {0}                };
  97.     global RectSelectTool    :=    { 2,  1,        "RectSelect",     kDrag,        0,                {0}                };
  98.     global HandTool            :=  { 3,  1,        "HandTool",     kDrag,      0,              {0}                };
  99.     global CharTool         :=     { 4,  1,        "CharTool",     kClick,        0,                {0}                };
  100.     global FillTool            :=  { 5,  1,        "FillTool",        kClick,        0,                {1,0,0,1}        };
  101.     global AirBrush            :=  { 6,  1,        "AirBrush",        kMultiDrag, 0,                {1,0,0,1}        };
  102.     global PaintBrush        :=    { 7,  1,         "PaintBrush",    kMultiDrag,    0,                {1,1,0,1}        };
  103.     global PencilTool        :=  { 8,  1,        "PencilTool",    kMultiDrag,    0,                {1,0,0,1}        };
  104.     global RectTool         :=     {9,  1,            "Rectangle",    kDrag,        0,                {1,1,1,1}        };
  105.     global Eraser            :=  {10,  1,        "Eraser",        kMultiDrag, 0,                {0}                };
  106.     global OvalTool         :=     {11,  1,        "Oval",            kDrag,         0,                {1,1,1,1}        };
  107.     global PolyTool         :=     {12,  1,         "Polygon",        kMultiClick,1,                {1,1,1,1}        };
  108.     global LineTool         :=     {13,  1,         "Line",            kDrag,         0,                {1,0,1,0}        };
  109.     global CurveTool         :=     {14,  1,         "Curve",        kDragClick, 0,                {1,1,1,1}        };
  110.     global PositionTool        :=  {15,  1,        "PositionTool", kMultiDrag,    0,                {0}                };
  111.     global ColorPickup        :=  {16,  1,        "ColorPickup",    kClick,        0,                {0}                };
  112.  
  113.  
  114. theMachine := gestalt('mach');                #Test to see if this is a black and white machine
  115.  
  116. if ( theMachine < 6 or theMachine = 9 or theMachine = 21 or theMachine = 23 or theMachine = 24 or theMachine = 25 or theMachine = 26) 
  117. begin
  118.     SE30With2Monitors := 0;
  119.     if (GestaltMachineType(theMachine) = 'MacSE030')  #Is this an SE30?
  120.     begin
  121.         monitorList     := collect[screen];   
  122.  
  123.         if ( monitorList.p > 1 )                        # Is the main monitor greater than 1 bit?            
  124.             SE30With2Monitors := 1;
  125.  
  126.         if card(monitorList > 1)                        # If there's a second monitor...
  127.         begin
  128.             if (monitorList[2].p > 1)                    # is the second monitor greater than 1 bit?
  129.                 SE30With2Monitors := 1;
  130.         end;
  131.         
  132.         if not(SE30With2Monitors)
  133.         begin
  134.             global gPaletteList := {
  135.                                     {     
  136.                                     { 0,58, 51,223,1},            #Main Tool Matrix (Pallete #1)
  137.                                     kPalDocWind,
  138.                                     {2,8},                        #tool matrix
  139.                                     {26,20}                        #tool offset
  140.                                     },
  141.         
  142.                                     {     
  143.                                     { 18,270, 53,256,1 },        #Color Matrix (Pallete #2)
  144.                                     kPopUpPal,
  145.                                     {16,16},                    #tool matrix
  146.                                     {8,8}                        #tool offset
  147.                                     },
  148.         
  149.                                     {     
  150.                                     {30,300, 57,215,1},            #Pattern Matrix (Pallete #3)
  151.                                     kPopUpPal,
  152.                                     {8,8},                        #tool matrix
  153.                                     {20,20}                        #tool offset
  154.                                     },
  155.                                     
  156.                                     {                                 
  157.                                     { 23,307, 23,342 },            #Line Weight Matrix (Pallete #4)
  158.                                     kPalDocWind,
  159.                                     {1,5},                        #tool matrix
  160.                                     {0,5}                        #tool offset
  161.                                     }
  162.                                 };
  163.  
  164.             ### Palette Elements:=        Tool#, Pal#,     ToolName,         ToolType,    DblClktoEnd        SetAttributes
  165.             global FreeSelectTool     :=     { 1,  1,        "FreeSelect",    kMultiDrag, 0,                {0}                };
  166.             global RectSelectTool    :=    { 2,  1,        "RectSelect",     kDrag,        0,                {0}                };
  167.             global HandTool            :=  { 3,  1,        "HandTool",     kDrag,      0,              {0}                };
  168.             global CharTool         :=     { 4,  1,        "CharTool",     kClick,        0,                {0}        };
  169.             global FillTool            :=  { 5,  1,        "FillTool",        kClick,        0,                {0}                };
  170.             global AirBrush            :=  { 6,  1,        "AirBrush",        kMultiDrag, 0,                {0}                };
  171.             global PaintBrush        :=    { 7,  1,         "PaintBrush",    kMultiDrag,    0,                {1,1,0,0}        };
  172.             global PencilTool        :=  { 8,  1,        "PencilTool",    kMultiDrag,    0,                {0}                };
  173.             global RectTool         :=     { 9,  1,        "Rectangle",    kDrag,        0,                {1,1,1,1}        };
  174.             global Eraser            :=  {10,  1,        "Eraser",        kMultiDrag, 0,                {0}                };
  175.             global OvalTool         :=     {11,  1,        "Oval",            kDrag,         0,                {1,1,1,0}        };
  176.             global PolyTool         :=     {12,  1,         "Polygon",        kMultiClick,1,                {1,1,1,0}        };
  177.             global LineTool         :=     {13,  1,         "Line",            kDrag,         0,                {1,0,1,0}        };
  178.             global CurveTool         :=     {14,  1,         "Curve",        kDragClick, 0,                {1,1,1,0}        };
  179.             global PositionTool        :=  {15,  1,        "PositionTool", kMultiDrag,    0,                {0}                };
  180.             global ColorPickup        :=  {16,  1,        "ColorPickup",    kClick,        0,                {0}                };
  181.         end;
  182.  
  183.     end;
  184. end;
  185.  
  186.     global gToolList:={    
  187.                         global RectSelectTool,
  188.                         global HandTool,
  189.                         #global CharTool,
  190.                         global FillTool,
  191.                         global AirBrush,
  192.                         global PaintBrush,
  193.                         global PencilTool,
  194.                         global RectTool,
  195.                         global Eraser,
  196.                         global OvalTool,
  197.                         global PolyTool,
  198.                         global LineTool,
  199.                         global CurveTool,
  200.                         global PositionTool,
  201.                         global ColorPickup
  202.                     };
  203.                     
  204.         global gToolList:={    CurveTool, OvalTool }; 
  205.  
  206.         ### font characteristic lists
  207.     global gFontSizeList := {'9','10','12','14','18', '24','36','48','72'};
  208.     global gFontStyleList := {'Bold','Italic','Outline', 'Underline','Shadow'};
  209.  
  210.         ### Name of the Plain (style) menu item  ####
  211.     global gPlainStyle := "Plain";            # Plain-Style menu item
  212.  
  213.         ### How to get to the next line
  214.     global gNextLineMethod := 1;            
  215.         ### 1 - ReturnKey,  2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
  216.     
  217.         ### Does moving to the next line clear all font info
  218.     global gNextLineClearsFontSettings := 0;
  219.     
  220.         global gWindowInset := {60,20,20,20};    # Inset to wind to get content region
  221.  
  222. end;  # InitAppGlobals
  223.  
  224. #########################################################################
  225. #                            SetupDirectorForDraw()
  226. #========================================================================
  227. # Author:        GS (x25506)
  228. # Description:    Will make sure that Director is in Studio mode and that
  229. #                the paint window is open and zoomed and that the cast window is open.
  230. # Parameters:    None
  231. # Returns:        Nothing
  232. # Examples:        SetupDirectorForDraw();
  233. # Assumptions:    Director has launched 
  234. #========================================================================
  235. # History:
  236. #
  237. #########################################################################
  238. task SetupDirectorForDraw()
  239. begin
  240.     ToStudio();                                # Make sure we're in Studio
  241.     SetFrontWindow('Paint');                # Make sure the Paint Window's open
  242.     SizeWindow(515,385);                    # make sure all palettes available
  243. end;
  244.  
  245. #########################################################################
  246. #                            DirectorScrapText()
  247. #========================================================================
  248. # Author:        GS (x25506)
  249. # Description:    Test Scraptext
  250. # Parameters:    None
  251. # Returns:        Nothing
  252. # Examples:        DirectorScrapText();
  253. # Assumptions:    Director has launched 
  254. #========================================================================
  255. # History:
  256. #
  257. #########################################################################
  258. task DirectorScrapText()
  259. begin
  260.     logstr("Setting up for scraptext");
  261.     SelectMenuItem("Text","Window");
  262.     MoveRelativeToWindow(,,"Text",2);
  263.     Scrapbook(global kScrapTEXT);
  264.     CloseWindow(,,"Text");
  265.     SelectMenuItem("Paint","Window");    # get ready for scrappict
  266. end;
  267.  
  268. #########################################################################
  269. #                            DoTextDirector()
  270. #========================================================================
  271. # Author:        GS (x25506)
  272. # Description:    Test Text
  273. # Parameters:    None
  274. # Returns:        Nothing
  275. # Examples:        DoTextDirector();
  276. # Assumptions:    Director has launched 
  277. #========================================================================
  278. # History:
  279. #
  280. #########################################################################
  281. task DoTextDirector()
  282. begin
  283.     logstr("Setting up for DoText");
  284.     Draw(global CharTool);
  285.     DoText();
  286. end;
  287.  
  288. #########################################################################
  289. #                            DoDrawDirector()
  290. #========================================================================
  291. # Author:        GS (x25506)
  292. # Description:    Test Draw
  293. # Parameters:    None
  294. # Returns:        Nothing
  295. # Examples:        DoDrawDirector();
  296. # Assumptions:    Director has launched 
  297. #========================================================================
  298. # History:
  299. #
  300. #########################################################################
  301. task DoDrawDirector()
  302. begin
  303.     SetupDirectorForDraw();
  304.     DoDraw();
  305. end;
  306.  
  307. #########################################################################
  308. #                            DirectorModifyDocument()
  309. #========================================================================
  310. # Author:        ML
  311. # Description:    Modify Director Document
  312. # Parameters:    None
  313. # Returns:        Nothing
  314. # Examples:        DirectorModifyDocument();
  315. # Assumptions:    None 
  316. # Applications:    Canvas
  317. #========================================================================
  318. # History:
  319. #
  320. #########################################################################
  321. task DirectorModifyDocument()
  322. begin
  323.     Logstr("Modifying document...");
  324.     theReturn := Scrapbook(global kScrapPICT);
  325.     if match [button t:"Paste and Replace Cast"]!;
  326.         SelectButton("Paste and Replace Cast");
  327.     if match [button t:"Remap Colors"]!;
  328.         SelectButton("Remap Colors");
  329.     return(theReturn);
  330. end;
  331.  
  332. #########################################################################
  333. #                            ToStudio()
  334. #========================================================================
  335. # Author:             KTA (x45604)
  336. # Description:        Will Make sure that the current module is  Studio by checking
  337. #                    for the 'To Studio' menuItem if its there it will select it.
  338. # Applications:        Director in either module.
  339. ################################################################################    
  340. task ToStudio() begin
  341.     Studio := match[menuitem o:1 m:[menu o:2]];
  342.     if (Studio.t = 'To Studio') 
  343.         selectMenuItem("To Studio", "File");
  344.     else 
  345.         LogStr("Studio is the current module.",3);
  346. end;
  347.  
  348.  
  349.  
  350. ################################################################################
  351. # Name:                SetFrontWindow(windowName)        Author: DM (x41220)
  352. # Description:        Brings specified window to the front.
  353. # Params:            WindowName - Use names in window menu
  354. # Applications:        Director in either module.
  355. ################################################################################    
  356. task SetFrontWindow(windowName) begin
  357.     if not (match[window t:/≈"{windowName}"/ o:1]!)
  358.         SelectMenuItem(windowName, "Window");
  359. end;
  360.  
  361.  
  362. #########################################################################
  363. #                            Animate()
  364. #========================================================================
  365. # Author:        KTA
  366. # Description:    Will Move to a location on the Screen hold down the 'Option' and "Command' 
  367. #                Key while dragging the mouse to Animate in real time.
  368. # Parameters:    None
  369. # Returns:        Nothing
  370. # Examples:        Animate();
  371. # Assumptions:    None 
  372. # Applications:        Director in the Studio Module. With a cast member selected and only the Cast window Open (Panel Window is OK if it open)
  373. #                    This task is equivelant to a Views() task in other QLz.
  374. #========================================================================
  375. # History:
  376. #
  377. #########################################################################
  378. task Animate() begin
  379.     
  380.     SelectMenuItem( "Paint", "Window");
  381.     
  382.     MoveRelativeToWindow(30,30,'Stage');
  383.     pressKey k:{OptionKey, commandKey};
  384.     pressMouse;
  385.     
  386.     for x := 1 to 4
  387.         MoveRelativeToWindow(,,'Stage');
  388.     LogStr('Animating in Real time',3);
  389.     
  390.     releaseMouse;
  391.     releaseKey k:{OptionKey, commandKey};
  392.     wait(30);
  393.     selectMenuItem("Stop", "Control");
  394.     SetFrontWindow("Panel");                    # Open the Cast Window
  395.     selectMenuItem("Paint", "Window");            # get ready for dowindow
  396. end;
  397.  
  398. ################################################################################
  399. ####################             Main script                    ####################
  400. ################################################################################
  401. script Director (ScriptLevel:= -1)
  402. begin
  403.     InitGlobals(ScriptLevel);            # initialize your general globals
  404.     InitDraw();
  405.     InitFonts();
  406.     Global gApptitle := "MacroMind Director";
  407.     global gAppVersion := '3';        # version of app you will be running
  408.     SuiteStart('Director.vu');                    # begin a new test suite
  409.     if LaunchTwitch("{gAppTitle}",gAliasDirectory) # launch or twitch to your app
  410.     begin
  411.         global gFileName := "@!@-{gBuildVers}-Director";    # This is used in NameOK when saving files
  412.         global gCustomScrapText:= task DirectorScrapText;     # define app specific task    
  413.         global gModifyDocument:= task DirectorModifyDocument; # define app specific task
  414.         InitAppGlobals();                                    # init app specific globals
  415.         (*
  416.         *)
  417.         DoSetUpApp(,,,,1,1,1);
  418.         Logstr ("!@#$% Expected errors above - '!@#$% No open window with grow and
  419.         zoom boxes' and '!@#$% It appears that the wrong file was opened, BuckWheat
  420.         - undefined' because SF Get does not open a document window");
  421.         DoDrawDirector();
  422.         DoTextDirector();
  423.         Animate();
  424.         DoWindow();                                    
  425.         DoCloseApp(1);
  426.         if match [Button t:"OK"]!
  427.             SelectButton("OK");
  428.     end; # if LaunchTwitch("{gAppTitle}",gAliasDirectory)
  429.     SuiteEnd();
  430. end; # script Director
  431.